home *** CD-ROM | disk | FTP | other *** search
/ The PC-SIG Library 10 / The PC-Sig Library - Shareware for the IBM PC and Compatibles (PC-SIG)(Tenth Edition Disks 1-2804)(1991).iso / PC_SIGCD / 06 / 8 / DISK0685.ZIP / FORTH.ARC / 4TH-UG.DOC < prev    next >
Text File  |  1987-05-17  |  95KB  |  2,150 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.                                      User's Guide for
  12.  
  13.  
  14.                                    8086/8088 FIG-FORTH
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.                                        Release 1.0
  22.  
  23.                                   With Compiler Security
  24.                                            and
  25.                                   Variable Length Words
  26.  
  27.  
  28.                                         March 1981
  29.  
  30.  
  31.  
  32.                              ================================
  33.  
  34.  
  35.                            MS-DOS File Interface and Revisions
  36.  
  37.                                         July 1983
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.                This program and documentation are released  to  the  public
  45.                domain.  The FIG-FORTH listing  is  made  available  by  the
  46.                FORTH Interest Group, P.O. Box 8231, San Jose, CA 95155.
  47.  
  48.                Modified for MS-DOS and documented by J.E.   Smith,  U.   of
  49.                Penn./Dept.of  Chem,  Philadelphia,  PA   19104   (to   whom
  50.                inquiries should be directed). 
  51.  
  52.                Any  further  distribution  of  this  software  is  strictly
  53.                encouraged, as long as you don't get rich and  keep  it  all
  54.                for yourself. 
  55.  
  56.                If you modify this revised version  and  re-distribute  your
  57.                own version, it would be polite  to  notify  the  author  of
  58.                these  revisions,  and  to  take  responsibility  for   your
  59.                modifications. 
  60.  
  61.           8086/8088 FIG-FORTH User's Guide                      Page 2
  62.  
  63.  
  64.  
  65.  
  66.  
  67.           2.0  Quick Reference
  68.  
  69.           This is a summary of information necessary to use  FIG-FORTH
  70.           and its documentation. 
  71.  
  72.  
  73.           2.1  System Requirements
  74.  
  75.           FORTH requires the following system resources:
  76.  
  77.                 * an 8086 or 8088 CPU running MS-DOS version  1.10  or
  78.                   1.25
  79.  
  80.                 * 64K of available RAM, or about 100K total
  81.  
  82.                 * one or two disk drives
  83.  
  84.  
  85.  
  86.           2.2  Invocation
  87.  
  88.           FORTH is started by typing the following in response to  the
  89.           COMMAND prompt. 
  90.  
  91.                    FORTH <commands>
  92.  
  93.           Where <commands> is an optional list of FORTH  words  to  be
  94.           executed. 
  95.  
  96.           FORTH normally uses a special disk.  To  use  MS-DOS  files,
  97.           the following commands are available:
  98.  
  99.                    A:                      selects drive A
  100.                    B:                      selects drive B
  101.                    DIR" <filename>"        lists matching file information
  102.                    FILES" <filename>"      lists matching file names
  103.                    USING" <filename>"      selects <filename> for screen access
  104.                    EOF                     closes current screen file
  105.                    LOAD" <filename>"       loads the screens in <filename>
  106.                    ERASE" <filename>"      erases any matching files
  107.  
  108.  
  109.           Note:   NEVER change any disk while  FORTH  is  using  a
  110.                   file on that  disk!   Study  the  section  below
  111.                   regarding disk operations. 
  112.  
  113.           8086/8088 FIG-FORTH User's Guide                      Page 3
  114.  
  115.  
  116.  
  117.  
  118.  
  119.           2.3  Provided Documentation
  120.  
  121.           This document contains three main sections:
  122.  
  123.                 * FORTH user's guide
  124.                   The user's guide tells you how to  use  the  special
  125.                   features in this version of FORTH. 
  126.  
  127.                 * FORTH technical reference
  128.                   The   technical   reference   contains   information
  129.                   regarding modifications and additions to  the  FORTH
  130.                   interpreter/compiler    relative    to    the    FIG
  131.                   implementation. 
  132.  
  133.                 * FORTH glossary
  134.                   This is a list and explanation of  each  FORTH  word
  135.                   which has been changed or added to this  version  of
  136.                   FORTH. 
  137.  
  138.           8086/8088 FIG-FORTH User's Guide                      Page 4
  139.  
  140.  
  141.  
  142.  
  143.  
  144.           3.0  Introduction
  145.  
  146.           This document describes changes and additions  to  FIG-FORTH
  147.           v1.0 which is distributed by the
  148.  
  149.                    FORTH Interest Group
  150.                    P.O. Box 8231
  151.                    San Jose, CA  95155
  152.  
  153.           as modified to run under MS-DOS by
  154.  
  155.                    Joe Smith
  156.                    University of Pennsylvania
  157.                    Dept. of Chemistry
  158.                    250 S. 33rd St. 
  159.                    Philadelphia, PA  19104
  160.  
  161.           This  software  and  the   accompanying   documentation   is
  162.           available from
  163.  
  164.                    SIG/86
  165.                    c/o Joseph Boykin
  166.                    47-4 Sheridan Dr. 
  167.                    Shrewsbury, MA  01545
  168.  
  169.           This  version  of  FIG-FORTH  incorporates   a   number   of
  170.           significant changes to the FIG version.  The following is  a
  171.           partial list:
  172.  
  173.                 * written for Microsoft's MACRO-86 assembler
  174.  
  175.                 * full MS-DOS file interaction, as well as usual FORTH
  176.                   disk access
  177.  
  178.                 * all i/o is vectored and may  be  re-directed  within
  179.                   FORTH
  180.  
  181.                 * command line interpretation
  182.  
  183.  
  184.           Modifications   to   the   FIG-FORTH   implementation   were
  185.           undertaken to alleviate several problems.   First,  the  FIG
  186.           version is  for  CP/M-86.   Once  FORTH  was  running  under
  187.           MS-DOS,  the  lack  of  a   file   interface   soon   became
  188.           intolerable.   Also,  the  assembly   source   for   Seattle
  189.           Computer's assembler was not transportable to  other  MS-DOS
  190.           systems.  The translation to Microsoft's MACRO-86 was  begun
  191.           in January  of  1983  and  the  file  system  interface  was
  192.           completed the following June. 
  193.  
  194.           My original goal was to install a language for my  own  use.
  195.           That is still my primary concern.  Accordingly, this version
  196.           of the language is recommended for people who  are  familiar
  197.  
  198.           8086/8088 FIG-FORTH User's Guide                      Page 5
  199.  
  200.  
  201.  
  202.           with  their  computer,  and  (somewhat   less   importantly)
  203.           familiar with FORTH.  If you are new to FORTH, you will have
  204.           to dig for some of the  basic  information.   (some  helpful
  205.           references are listed at the end of this guide).  If you are
  206.           a person who enjoys understanding  and  tinkering  with  the
  207.           mechanisms (read 'hacker') you should feel  right  at  home.
  208.           If you are an experienced FORTH wizard, you can tell me  all
  209.           the things I did wrong! 
  210.  
  211.           The  author (J.E.S.) gratefully acknowledges the efforts  of 
  212.           the  FORTH  Interest Group (FIG) in providing  FORTH  source  
  213.           code.   FORTH  owes much of its popularity  to the  work  of  
  214.           this organization, it was the first significant software  to 
  215.           run  on my system (even before I had disks) and without them 
  216.           this implementation would certainly not exist. 
  217.  
  218.           Also, special  thanks  to  Joseph  Boykin,  whose  TOP  text
  219.           processor formatted this document.
  220.  
  221.           8086/8088 FIG-FORTH User's Guide                      Page 6
  222.  
  223.  
  224.  
  225.  
  226.  
  227.           4.0  User's Guide
  228.  
  229.           This documentation presents specific  details  necessary  to
  230.           use this version of FORTH under MS-DOS.  It is not a  user's
  231.           guide to FORTH in general.  Several introductory  references
  232.           are given at the end of this guide
  233.  
  234.  
  235.           4.1  System Requirements
  236.  
  237.           The FORTH interpreter/compiler as distributed requires:
  238.  
  239.                 * an 8086/8088 computer running MS-DOS version 1.10 or
  240.                   1.25
  241.  
  242.                 * 64K of RAM, or 96K total,  including  the  operating
  243.                   system
  244.  
  245.                 * one or more disk drives
  246.  
  247.           These  requirements   may   be   changed   to   almost   any
  248.           configuration by changing options in the assembly source and
  249.           re-assembling.  This process requires:
  250.  
  251.                 * All of the above requirements, plus another  64K  of
  252.                   RAM, or 128K total (for MACRO-86)
  253.  
  254.                 * the MACRO-86 macro assembler, or its equivalent
  255.  
  256.                 * the LINK-86 linker, or its equivalent
  257.  
  258.                 * the EXE2BIN program to convert the linker output  to
  259.                   a .COM file
  260.  
  261.           See the section below, "Modifying FORTH", and the  technical
  262.           reference for further information.
  263.  
  264.           8086/8088 FIG-FORTH User's Guide                      Page 7
  265.  
  266.  
  267.  
  268.  
  269.  
  270.           4.2  FORTH, Calculator Style
  271.  
  272.           The simplest mode of interaction with FORTH is  through  the
  273.           system console.  You type commands,  FORTH  interprets  them
  274.           and carries out your  orders;  much  the  same  as  using  a
  275.           powerful, programmable calculator. 
  276.  
  277.  
  278.           4.2.1  Getting Started
  279.  
  280.           FORTH is invoked from MS-DOS by typing:
  281.  
  282.                    FORTH <optional command list>
  283.  
  284.           in response to COMMAND's prompt.  This will load and execute
  285.           the FORTH interpreter.  FORTH  will  initialize  itself  and
  286.           print a banner something like
  287.  
  288.                    8086 FIG-FORTH Version 1.1A
  289.  
  290.           Then, FORTH begins executing any commands you give  it.   If
  291.           there  was  anything  else  on  the   command   line,   i.e.
  292.           <command list> was present, FORTH attempts to interpret  it.
  293.           Thus, if you wanted to find out what 8086  is  in  hex,  you
  294.           could type:
  295.  
  296.                    A:FORTH 8086 HEX . BYE
  297.  
  298.           and FORTH would reply:
  299.  
  300.                    8086 FIG-FORTH Version 1.1A
  301.  
  302.                    1F96
  303.                    A:
  304.  
  305.           If nothing was passed on  the  command  line,  FORTH  simply
  306.           types a carriage return and waits for you.  The command list
  307.           is limited to a total of  80  characters.   If  you  type  a
  308.           carriage return at this point, FORTH should  respond:  "ok".
  309.           If it doesn't, you have a problem. 
  310.  
  311.  
  312.           4.2.2  Communicating With FORTH
  313.  
  314.           Keyboard entries are  handled  by  the  FORTH  word  EXPECT.
  315.           EXPECT only recognizes two special keys: <DELETE> and  <CR>.
  316.           Any other key is presumed  to  be  a  valid  character.   No
  317.           MS-DOS editing functions are available.  The exact key which
  318.           FORTH recognizes as <DELETE> defaults to  ASCII  DEL.   This
  319.           may be easily changed to any other key.  The  section  below
  320.           on  modifying  FORTH  tells  how  to  change  the  backspace
  321.           character.  If you type <DELETE>,  EXPECT  will  delete  the
  322.           last character entered.  If you try to go past the beginning
  323.  
  324.           8086/8088 FIG-FORTH User's Guide                      Page 8
  325.  
  326.  
  327.  
  328.           of the line, the terminal should beep and leave  the  cursor
  329.           in the first column. 
  330.  
  331.  
  332.           4.2.3  Special Functions
  333.  
  334.           While no editing functions are provided, MS-DOS does respond
  335.           to some other special  keys.   Any  console  output  may  be
  336.           paused by typing ^S.  Printer output is toggled using ^P/^N.
  337.           Because MS-DOS intercepts these keys, FORTH will  never  see
  338.           them.  Another function, the interrupt key ^C, has  variable
  339.           effects.   Normally,  pressing  ^C  causes   the   currently
  340.           executing FORTH word to be interrupted.  Control  is  passed
  341.           to the FORTH word (ABORT) which usually aborts  the  current
  342.           word and  resets  the  interpreter.   This  process  may  be
  343.           changed to  provide  more  intelligent  interrupt  handling.
  344.           Refer to the last part of the technical reference section on
  345.           "Modifying FORTH" for more information. 
  346.  
  347.           There are a number of assembly options which may affect  the
  348.           exact  way  these  keys  are  handled.   See  the  technical
  349.           reference section entitled "installation dependent code" for
  350.           further information. 
  351.  
  352.  
  353.           4.2.4  New Definitions
  354.  
  355.           One command FORTH accepts is the  colon  ":".   Colon  is  a
  356.           command to begin compiling  the  following  text  as  a  new
  357.           definition.  No "ok" will appear until you have successfully
  358.           completed your definition and ended it with a semicolon ";".
  359.           The definition may be spread out over as many lines  as  you
  360.           need, up to 80 characters on each line.   Until  you  end  a
  361.           line by typing <CR>, you may back up and  change  it.   Once
  362.           you go on to the next line, no editing is  possible.   FORTH
  363.           will make you aware of any errors in the definition.  If you
  364.           make a mistake, the whole definition must be entered again. 
  365.  
  366.           Try the following definition:
  367.  
  368.                : STAR 42 EMIT ;
  369.  
  370.           FORTH should respond "ok" after you hit  return.   Now  test
  371.           STAR by typing: STAR<CR>.  FORTH  should  print  "*ok".   If
  372.           that worked, try this one:
  373.  
  374.                : MILKY-WAY
  375.                  BEGIN
  376.                     STAR SPACE SPACE
  377.                     ?TERMINAL
  378.                  UNTIL ;
  379.  
  380.           Remember, no "ok" will  be  printed  until  you  finish  the
  381.           definition with  the  semicolon.   Any  leading  spaces  are
  382.           ignored.  Test MILKY-WAY as with STAR.  When you  get  tired
  383.  
  384.           8086/8088 FIG-FORTH User's Guide                      Page 9
  385.  
  386.  
  387.  
  388.           of star-gazing, stop the program by hitting  any  key.   The
  389.           stars  should  stop,  and  FORTH  should  inform  you   that
  390.           everything is "ok".  You can also  pause  the  execution  of
  391.           MILKY-WAY using ^S, or abort it using ^C. 
  392.  
  393.           You can experiment with other definitions, but having no way
  394.           of modifying  the  functions  without  re-typing  them  soon
  395.           becomes a serious problem.  The next section  tells  how  to
  396.           edit and load definitions stored on your  disk.   Don't  try
  397.           any disk operations until you have read the next section. 
  398.  
  399.  
  400.           4.2.5  Exiting FORTH
  401.  
  402.           To return to MS-DOS, say "BYE" to FORTH.
  403.  
  404.           8086/8088 FIG-FORTH User's Guide                     Page 10
  405.  
  406.  
  407.  
  408.  
  409.  
  410.           4.3  Using the Disk
  411.  
  412.           Standard FORTH supports only  the  most  primitive  of  file
  413.           structures.  FORTH views the  disk  as  a  linear  array  of
  414.           blocks which may be accessed in any  order.   A  disk  block
  415.           formatted as 16 lines of 64 characters is called  a  screen.
  416.           In  the  standard  configuration,  FIG-FORTH  bypasses   the
  417.           operating system file structure.  This means that FORTH must
  418.           have a disk all to itself.  While there  are  advantages  to
  419.           this  arrangement  (no  directory  overhead,   simple   disk
  420.           interface,  portability  across   operating   systems,   for
  421.           instance),  it  is  often  inconvenient  that  FORTH  should
  422.           totally ignore its host operating system's files. 
  423.  
  424.           To deal with this conflict, and yet  maintain  compatibility
  425.           with standard FORTH disk access,  the  FIG-FORTH  model  was
  426.           changed.  The words which do all disk access, BLOCK-READ and
  427.           BLOCK-WRITE, can now be assigned to any function.  Thus,  by
  428.           telling BLOCK-READ/WRITE to use a file instead of  the  disk
  429.           directly, all of the standard FORTH disk words will refer to
  430.           blocks of that file.  The user can easily switch between the
  431.           two modes, or use one exclusively.  Also, all of  the  usual
  432.           disk words will work on a file as  well  as  the  old  FORTH
  433.           disk. 
  434.  
  435.  
  436.           4.3.1  Creating and Editing Definitions
  437.  
  438.           There  are  three  editors  distributed  with  the  package.
  439.           Unfortunately, there isn't time or space to  describe  their
  440.           use  here.   All  are  described  elsewhere,  however.   The
  441.           editors provided include:
  442.  
  443.                 * two line-oriented editors: the  FORTH  Inc.   editor
  444.                   described in Leo Brodie's "STARTING FORTH"  and  the
  445.                   FIG   portable   editor   described   in   the   FIG
  446.                   installation manual. 
  447.  
  448.                 * a screen editor described  in  Dr.   Dobb's  Journal
  449.                   No. 59.  This editor is configured for the Televideo
  450.                   950 terminal, and must be  modified  for  any  other
  451.                   terminal. 
  452.  
  453.           Any of these may be used with either screen files  or  FORTH
  454.           disks.  All examples in this guide will refer to the  editor
  455.           described by Brodie, which has been compiled and included in
  456.           the FORTH.COM file. 
  457.  
  458.           8086/8088 FIG-FORTH User's Guide                     Page 11
  459.  
  460.  
  461.  
  462.           4.3.2  FORTH Disk Access
  463.  
  464.           After a COLD start, any disk words will access a FORTH disk.
  465.           If you start FORTH and type "4 LIST",  it  assumes  you  are
  466.           asking to see the fourth disk block.  In this mode, all disk
  467.           transfers bypass the file system.  The user  has  access  to
  468.           all blocks on the  disk,  and  if  more  than  one  disk  is
  469.           available, FORTH will treat them as one disk  of  twice  the
  470.           capacity. 
  471.  
  472.           Once you use a screen file, you must execute SWITCH  to  get
  473.           back to the FORTH disk.  This should remind you to  "switch"
  474.           your FIG-FORTH disk for the MS-DOS disk. 
  475.  
  476.           The disk interface allows you to use only one  format  at  a
  477.           time.   That  is,  FORTH  cannot  automatically   adapt   to
  478.           different  FORTH  disk  formats  the  way  MS-DOS  can.   By
  479.           changing the constants  that  describe  the  disk,  you  can
  480.           manually change formats to any supported by your i/o system. 
  481.  
  482.           To find what format FORTH expects, type
  483.  
  484.                    B/BUF REC/BLK / . 
  485.  
  486.           This gives the sector  size  in  bytes.   To  determine  the
  487.           capacity of the disk FORTH expects,  display  the  constants
  488.           BLK/DRIVE, MAXDRIVE, and MAXBLOCK. 
  489.  
  490.           The 8-inch format is 128 bytes/sector, 52 sectors/track,  77
  491.           tracks per disk.  The 5-inch disks are 512  bytes/sector,  8
  492.           sectors/track, 40 tracks per disk. 
  493.  
  494.  
  495.  
  496.           4.3.3  Screen File Access
  497.  
  498.           This version of FORTH includes an interface  to  the  MS-DOS
  499.           file system.  The assembly source includes a low level  file
  500.           interface, but the higher level functions must  be  compiled
  501.           from a  FORTH  disk.   See  the  following  section  in  the
  502.           technical reference on "Modifying FORTH"  for  details.   In
  503.           order to switch from the FORTH disk to a screen file, type
  504.  
  505.                    USING" <filename>"
  506.  
  507.           where <filename> is any legal, unambiguous MS-DOS  filename.
  508.           FORTH will attempt to open the file and determine if it is a
  509.           file of FORTH screens.  If all goes well,  FORTH  will  tell
  510.           you how many blocks are available in that  file.   The  file
  511.           will look just like the disk to FORTH,  except its  capacity
  512.           will be smaller.  Screen files may not span disks.   If  the
  513.           specified file doesn't exist, FORTH will create it but  will
  514.           not  allocate  any  space  to  it.   The  following  example
  515.           demonstrates the screen file access words. 
  516.  
  517.           8086/8088 FIG-FORTH User's Guide                     Page 12
  518.  
  519.  
  520.  
  521.           Start FORTH, and type
  522.  
  523.                    USING" TRYIT"
  524.  
  525.           FORTH will create a file named TRYIT.SCR and tell  you  that
  526.           the file is empty.  To use the file, you must allocate  some
  527.           space to it.  This is done by entering
  528.  
  529.                    2 EXTEND
  530.  
  531.           EXTEND takes the number on the  stack  and  adds  that  many
  532.           blocks to the end of the screen file.   In  this  case,  the
  533.           file is now 0+2 or 2 screens long (screens 0 and 1).  If you
  534.           were to try and list screen 2, you would get an error.  Note
  535.           that EXTEND does not put anything in the screens  allocated;
  536.           they contain whatever the disk held previously, but now they
  537.           belong to your current screen file.  Clear a working  screen
  538.           by entering the editor and filling screen one with blanks:
  539.  
  540.                    1 SCR ! 
  541.                    EDITOR
  542.                    WIPE
  543.  
  544.           List the screen, select line 0, and enter some text:
  545.  
  546.                    L
  547.                    0 T
  548.                    P ( this is screen 0 line 1 in file TRYIT.SCR )
  549.                    L
  550.  
  551.           Use FLUSH to save the changes, then  type  "L"  again.   The
  552.           screen should be just as  you  left  it.   Try  editing  the
  553.           definitions for STAR and MILKY-WAY onto this  screen.   When
  554.           you finish editing, save it by typing
  555.  
  556.                    EOF
  557.  
  558.           (End Of File) to close the file.  EOF displays the directory
  559.           entry of your file to verify that  everything  is  allright.
  560.           If the file is empty, EOF will notify you and then erase the
  561.           file. 
  562.  
  563.           You are now in limbo as far as the disk  is  concerned.   If
  564.           you try to access the disk, FORTH will remind you to specify
  565.           which kind of disk access you want  to  do:  file  or  FORTH
  566.           disk.  To list the screen again, tell FORTH to use TRYIT.SCR
  567.           (USING" TRYIT").  Now FORTH should find a file with 2 blocks
  568.           in it.  And  if  you  list  screen  1,  you  will  see  your
  569.           definitions, just as  you  left  them.   If  you  need  more
  570.           screens, use  EXTEND  as  before  to  allocate  more  space.
  571.           Remember to WIPE the screen as it will probably be  full  of
  572.           nasty control characters for your terminal to choke on! 
  573.  
  574.           Why not use screen 0?  Well, FORTH can list  screen  0,  and
  575.           you can edit text there, but if you try "0 LOAD", FORTH will
  576.  
  577.           8086/8088 FIG-FORTH User's Guide                     Page 13
  578.  
  579.  
  580.  
  581.           get very confused.  When FORTH compiles block 0, it actually
  582.           compiles input from the console.   Thus,  block  0  of  each
  583.           screen file cannot be loaded (but, see the following section
  584.           for one use for screen 0). 
  585.  
  586.  
  587.  
  588.           4.3.4  Compiling Definitions
  589.  
  590.  
  591.           As with editing, once you have opened a screen file, you can
  592.           proceed exactly as you would with a FORTH disk.  If you have 
  593.           edited  some  definitions  onto Screen 1,  compile  them  by 
  594.           typing 1 LOAD.  If FORTH says "ok", test them as before.  If 
  595.           there is an error, edit the definitions and try again.
  596.  
  597.           There is only one new word with  regard  to  loading  screen
  598.           files.  To make the process of selecting a screen  file  and
  599.           loading it more convenient, use. 
  600.  
  601.                    LOAD" <filename>"
  602.  
  603.           LOAD" opens  the  specified  file,  and  loads  the  screens
  604.           starting with screen one.  Since screen zero is just sitting
  605.           there with nothing to do, LOAD" lists  it  before  beginning
  606.           the load with screen one.  This is  a  good  place  for  any
  607.           special  messages,  advertisements,  secret  messages,  etc.
  608.           LOAD" is defined as simply:
  609.  
  610.                    : LOAD"
  611.                         USING"
  612.                         ( code to list screen 0 )
  613.                         1 LOAD
  614.                         EOF ;
  615.  
  616.           If an error is encountered during the LOAD, that  file  will
  617.           be the current screen file.
  618.  
  619.           8086/8088 FIG-FORTH User's Guide                     Page 14
  620.  
  621.  
  622.  
  623.  
  624.  
  625.           4.3.5  Other Functions
  626.  
  627.           There are several utility functions defined which make FORTH
  628.           more convenient to use with the file  system.   These  words
  629.           apply only to MS-DOS disks and not to FORTH disks. 
  630.  
  631.  
  632.           4.3.5.1  Changing the Default Drive
  633.  
  634.           As in COMMAND, typing
  635.  
  636.                    A:
  637.           or
  638.                    B:
  639.  
  640.           will change the default drive for all file access. 
  641.  
  642.  
  643.           4.3.5.2  Directory Information
  644.  
  645.           Several utilities are available for using MS-DOS disks.  Two
  646.           words which list the disk directory are defined:
  647.  
  648.                    DIR"   <filename>"
  649.                    FILES" <filename>"
  650.  
  651.           DIR" gives a complete directory  listing  of  each  matching
  652.           filename, similar to the MS-DOS DIR command.   FILES"  lists
  653.           only filenames, five  per  line,  much  as  the  MS-DOS  DIR
  654.           command with the "/W" option.  The exact  interpretation  of
  655.           ambiguous filenames differs from  COMMAND's.   The  filename
  656.           must not be blank,  and  any  part  of  the  name  left  out
  657.           defaults to "*".  Thus,
  658.  
  659.                    DIR" .SCR"     = DIR *.SCR
  660.                    DIR" *"        = DIR *
  661.                    DIR" ALL."     = DIR ALL.*
  662.  
  663.           The trailing quote may be replaced with the carriage return,
  664.           and in fact, must be replaced to list  files  with  a  blank
  665.           extension:
  666.  
  667.                    DIR" .<CR>     =DIR *. 
  668.                    DIR" INDEX.<CR>=DIR INDEX. 
  669.  
  670.  
  671.           4.3.5.3  Erasing Files
  672.  
  673.           A function is provided to erase files:
  674.  
  675.                    ERASE" <filename>"
  676.  
  677.           The use of this command is similar to  the  directory  words
  678.  
  679.           8086/8088 FIG-FORTH User's Guide                     Page 15
  680.  
  681.  
  682.  
  683.           above, except that no  part  of  <filename>  has  a  default
  684.           value.  ERASE"  will  accept  ambiguous  filenames,  and  it
  685.           displays the name of each file it  erases.   No  warning  is
  686.           issued when the filename is "*.*", so beware! 
  687.  
  688.  
  689.           4.3.5.4  Screen Transfer
  690.  
  691.           To assist in copying screens between FORTH disks and  MS-DOS
  692.           files, two utilities are provided: COPY>FILE  and  COPY>SCR.
  693.           These function very simply.   COPY>FILE  directs  all  block
  694.           reads to the FIG-FORTH disk, and  all  disk  writes  to  the
  695.           current screen file.  COPY>SCR does the reverse.   Then  all
  696.           you need is the usual words for moving screens  around,  and
  697.           magically they appear at the destination.  The  actual  copy
  698.           operation is provided by the word #SCRCOPY, which takes  the
  699.           starting source screen, the starting destination screen  and
  700.           the number of screens to copy off the stack.  Thus,
  701.  
  702.                    USING" NEW"
  703.                    COPY>FILE ... 
  704.                    100 1 14 #SCRCOPY
  705.                    EOF
  706.  
  707.           would copy screens 100-113 on the FORTH disk to screens 1-14
  708.           in the file NEW.SCR.  Note that after you type  COPY>SCR  or
  709.           COPY>FILE, you can still LIST or INDEX the  source  disk  if
  710.           you forget which screens you want to copy. 
  711.  
  712.  
  713.           4.3.5.5  Screen File Status
  714.  
  715.           To check on the status of the current screen file,  you  can
  716.           use
  717.  
  718.                    SCREENS /? 
  719.  
  720.           If the screen file is in use, a display similar to the  DIR"
  721.           information is printed; for example,
  722.  
  723.                    A:FORTH   .SCR r w s     10240  06-28-1983  19:59
  724.  
  725.           If the EOF command is given and then /?   is  repeated,  the
  726.           following would be printed:
  727.  
  728.                    A:FORTH   .SCR r w s
  729.  
  730.           showing that the file is not in use.  The  "r w s"  indicate
  731.           that this is a screen or random access file (s),  which  may
  732.           be both read from (r) and written to (w). 
  733.  
  734.           An interesting discrepancy may arise between the DIR" report
  735.           and the /?  information.
  736.  
  737.           8086/8088 FIG-FORTH User's Guide                     Page 16
  738.  
  739.  
  740.  
  741.           Examine the following session:
  742.  
  743.                    USING" NEW" empty file
  744.                    5 EXTEND ok
  745.                    DIR" NEW.SCR" 
  746.                    B:NEW     .SCR          0  06-29-1983   0:26   1 file ok
  747.                    SCREENS /? 
  748.                    B:NEW     .SCR r w s       5120  06-29-1983   0:27    ok
  749.                    EOF ok
  750.                    B:NEW     .SCR       5120  06-29-1983   0:27   1 file ok
  751.                    SCREENS /? 
  752.                    B:NEW     .SCR r w s   ok
  753.  
  754.           The differences in the file size and time fields reflect the
  755.           operating system buffering the physical disk output.  The /?
  756.           display is taken from the  file  control  block  in  memory,
  757.           which is immediately updated,  while  the  DIR"  display  is
  758.           taken from the directory and is not updated  until  data  is
  759.           written to the disk when the file is closed by EOF.
  760.  
  761.           8086/8088 FIG-FORTH User's Guide                     Page 17
  762.  
  763.  
  764.  
  765.  
  766.  
  767.           4.3.5.6  Notes
  768.  
  769.           A  few  features  of  the  above  discussion  bear   further
  770.           emphasis. 
  771.  
  772.                 * NEVER change the disk FORTH  is  using  for  screens
  773.                   while the file is open.  Changing disks  haphazardly
  774.                   is a bad practice in almost all cases, not just  for
  775.                   FORTH.  As can be seen above, the  information  kept
  776.                   on the disk is not always accurate.  If the disk  is
  777.                   changed, the file parameters kept in memory will  be
  778.                   separated from the directory entry for the file, and
  779.                   disaster is almost certain to result. 
  780.  
  781.                 * In light of the above comments, note  that  you  may
  782.                   FLUSH FORTH's disk buffers, but  not  MS-DOS's  disk
  783.                   buffers.  Thus your disk buffers are not  guaranteed
  784.                   to be on the disk until you  close  the  file  using
  785.                   EOF.  If  the  file  interface  is  loaded,  BYE  is
  786.                   redefined to execute EOF before  exiting,  to  force
  787.                   any updated buffers to be saved. 
  788.  
  789.                 * Only one screen file may be active at  once.   FORTH
  790.                   checks this and will not allow another USING"  while
  791.                   the SCREENS file is in use.  This  restriction  only
  792.                   applies to screen files. 
  793.  
  794.                 * The FORTH disk is the default state after COLD,  but
  795.                   before an EOF.  You must specifically request access
  796.                   to a screen file.  Once you use a screen file, FORTH
  797.                   blocks any FORTH disk access until  you  request  it
  798.                   using SWITCH.  Accessing an MS-DOS disk as  a  FORTH
  799.                   disk probably won't destroy it, however, FORTH  will
  800.                   probably get upset and quit talking to  you.   FORTH
  801.                   tries to remind you to pay attention, but it doesn't
  802.                   try to protect you: the burden is  on  YOU  to  keep
  803.                   track of what you are doing! 
  804.  
  805.                 * There is a convention for  the  names  of  the  disk
  806.                   functions.  Since there are two names for each  file
  807.                   (see below) there are two ways to refer to  a  file.
  808.                   Names which begin with a "/" expect  an  address  on
  809.                   the stack.  Names which end in a double-quote expect
  810.                   a  filename,  delimited  by  a  trailing  quote,  to
  811.                   follow.  The  function  that  assigns  filenames  to
  812.                   files, therefore, has both: /IS". 
  813.  
  814.           8086/8088 FIG-FORTH User's Guide                     Page 18
  815.  
  816.  
  817.  
  818.           4.4  Modifying FORTH
  819.  
  820.           FORTH is an extremely  flexible  language.   With  a  little
  821.           effort you can make it your own  personal  environment.   In
  822.           addition, since you have the assembly source you can  change
  823.           the inner workings, making it more efficient.  The following
  824.           discussion  is  not  complete,  but  serves   only   as   an
  825.           introduction.  Exploring the territory is half the fun! 
  826.  
  827.  
  828.           4.4.1  FORTH Extensions
  829.  
  830.  
  831.           One of the nice things about FORTH is the ability to  extend
  832.           the language.  To complement  this  extensibility,  you  can
  833.           save the new FORTH in an executable file and the  extensions
  834.           become immediately available.  Only two things are necessary
  835.           to accomplish this: first,  FORTH's  cold  start  parameters
  836.           must be  updated;  and  second,  the  memory  image  of  the
  837.           modified FORTH must be saved in a file.   This  is  how  the
  838.           FORTH.COM file was constructed for distribution. 
  839.  
  840.           Updating the cold start parameters is  accomplished  by  the
  841.           FORTH word NEW.  Saving the new version can be done  in  two
  842.           ways:  first,  using  DEBUG  and  second,  the  FORTH   word
  843.           SAVE-FORTH" <filename>".  The FORTH word  SIZE?   will  tell
  844.           you the size of the FORTH kernel for writing from DEBUG.  To
  845.           use SAVE-FORTH, first execute NEW to lock the changes.  Make
  846.           sure no files are open before executing NEW, otherwise  they
  847.           will appear to be open when the new  FORTH  executes.   Then
  848.           define an output file and use SAVE-FORTH to write itself  to
  849.           the file.  Since the file was defined after NEW, it will not
  850.           appear in the new version.  Study the following hypothetical
  851.           example:
  852.  
  853.                    9 LOAD 100 LOAD 108 LOAD ok
  854.                    NEW ok
  855.                    current version is A
  856.                    new version (A-Z)? Bok
  857.                    >FILE S4 ok
  858.                    S4 /SAVE-FORTH" X4TH.COM"
  859.                    B:X4TH    .COM      12521  06-29-1983   0:27 ok
  860.  
  861.           Note that because the FIG-FORTH disk is the  default  state,
  862.           you must always modify and load the file definitions from  a
  863.           FORTH disk.  If you FORGET the file words, you can only  use
  864.           the FORTH disk! 
  865.  
  866.  
  867.           4.4.2  Patching
  868.  
  869.           Many of the parameters which affect the operation  of  FORTH
  870.           are placed in the boot parameter area  at  the  low  end  of
  871.           FORTH.  These may be freely modified using  DEBUG,  or  from
  872.           within FORTH.  On execution of COLD, these  parameters  will
  873.  
  874.           8086/8088 FIG-FORTH User's Guide                     Page 19
  875.  
  876.  
  877.  
  878.           be used to initialize the interpreter.  The patches can then
  879.           be made permanent as  described  above.   For  example,  the
  880.           following will change the FORTH backspace key:
  881.  
  882.                    KEY 14 +ORIGIN ! 
  883.  
  884.           After you type this and hit return, FORTH will wait for  you
  885.           to hit a key.  The key you type will be placed in  the  boot
  886.           parameters and will be recognized as  your  backspace.   The
  887.           other parameters in this area are clearly commented  in  the
  888.           assembly source, should you want to patch any of them. 
  889.  
  890.  
  891.           4.4.3  Assembly Source Modifications
  892.  
  893.           Re-assembly  of  FORTH  is  the  least  desirable  form   of
  894.           modification.  It is slow and can  be  difficult  to  debug.
  895.           However, there are modifications which are only possible  in
  896.           this way.  A  great  deal  of  time  has  gone  into  adding
  897.           comments to the assembly source so that you  can  understand
  898.           the way FORTH works.  Almost all of the  comments  appearing
  899.           in the FIG listing are in the new listing, along  with  some
  900.           additional comments.   There  is  more  information  on  the
  901.           assembly source in the technical reference portion  of  this
  902.           documentation. 
  903.  
  904.           Be aware of two problems here: first, it  is  very  easy  to
  905.           lose track of the changes you make.  so document and comment
  906.           each modification.  Second, more changes make  your  version
  907.           of FORTH  more  unique  (or  maybe  just  strange)  and  any
  908.           definitions using that feature  less  portable.   Don't  add
  909.           bells and whistles just to be different.
  910.  
  911.           8086/8088 FIG-FORTH User's Guide                     Page 20
  912.  
  913.  
  914.  
  915.  
  916.  
  917.           5.0  Technical Reference
  918.  
  919.           This section describes  changes  and  modifications  to  the
  920.           FIG-FORTH model.  It is not an explanation of the FIG model,
  921.           nor of how FORTH works.  The user should refer  to  the  FIG
  922.           installation manual for further information. 
  923.  
  924.  
  925.           5.1  Assembly Source
  926.  
  927.           The FIG assembly listing on which this version is based  was
  928.           written for the CPM/86 8086 assembler.  For MS-DOS, the  FIG
  929.           listing was translated  into  source  for  Seattle  Computer
  930.           Products 8086 assembler.   Since  the  latter  assembler  is
  931.           peculiar to SCP systems, the code was translated again  into
  932.           source for  Microsoft's  MACRO-86  macro  assembler,  to  be
  933.           portable to any MS-DOS environment. 
  934.  
  935.           Several features of MACRO-86 were used  to  provide  greater
  936.           flexibility.  First, macros were written to build dictionary
  937.           headers for each definition.  These macros make  setting  up
  938.           the dictionary entries  convenient,  but  more  importantly,
  939.           they calculate the link fields.  Because the  links  are  no
  940.           longer  based  on  specific  labels  in  the   source,   the
  941.           dictionary can be split into several files  which  are  then
  942.           INCLUDED at  the  appropriate  points.   This  allows  great
  943.           flexibility and modularity in assembling FORTH. 
  944.  
  945.  
  946.           5.1.1  Source File Organization
  947.  
  948.           The source is now broken into several separate files:
  949.  
  950.                 * 4TH-MAIN.ASM
  951.                   This is the primary file which INCLUDES  the  others
  952.                   during assembly.  It contains the inner interpreter,
  953.                   code-level kernel, and most of the FORTH vocabulary. 
  954.  
  955.                 * 4TH-SYSD.ASM
  956.                   This file contains (almost) all of the code which is
  957.                   operating system  or  hardware  dependent.   If  you
  958.                   wanted to transport FORTH  to  a  different  system,
  959.                   most of the changes would be in this file. 
  960.  
  961.                 * 4TH-DISK.ASM
  962.                   This file is INCLUDED by 4TH-SYSD and  contains  the
  963.                   actual  disk  interface  for  reading/writing   disk
  964.                   sectors. 
  965.  
  966.                 * 4TH-FILE.ASM
  967.                   Also (optionally) INCLUDED by SYSD,  this  file  has
  968.                   all of  the  words  that  deal  with  files  at  the
  969.                   operating system level.  This code is only assembled
  970.  
  971.           8086/8088 FIG-FORTH User's Guide                     Page 21
  972.  
  973.  
  974.  
  975.                   if the FILES option is set to TRUE. 
  976.  
  977.                 * 4TH-XTNS.ASM
  978.                   These definitions are code-level extensions  of  the
  979.                   FORTH dictionary.  These  include  array  addressing
  980.                   primitives, long fetch and store operators  and  the
  981.                   port i/o words.  MATCH is also in this  file.   This
  982.                   file is only assembled if the EXTEND option is TRUE. 
  983.  
  984.                 * 4TH-OPTS.H
  985.                   The assembly options  are  located  in  this  header
  986.                   file,  and  are  symbols  which   begin   with   the
  987.                   underscore character.  These are  global  parameters
  988.                   and are used by other modules.   All  other  equates
  989.                   and variables should be local to  the  module  where
  990.                   they are defined. 
  991.  
  992.                   It  is  unfortunate  that  the  modules  cannot   be
  993.                   separately assembled and linked.  The present system
  994.                   requires a lot of memory  and  about  5  minutes  to
  995.                   assemble (on an 8MHz  8086  using  8"  ssdd  disks).
  996.                   This is really tedious for making small changes! 
  997.  
  998.  
  999.           5.1.2  Macros
  1000.  
  1001.                   The macros necessary to assemble FORTH  are  in  the
  1002.                   file 4TH-LIB.MAC.  Comments in this file explain the
  1003.                   function  of  each  macro.   Beside  the  dictionary
  1004.                   macros, there are two macros to do branches  in  the
  1005.                   threaded definitions.  The  actions  of  the  macros
  1006.                   should be clear after studying their definitions and
  1007.                   the manner in which they are used in the code. 
  1008.  
  1009.  
  1010.           5.1.3  Comments
  1011.  
  1012.                   The  SCP  assembler  source  was   rather   sparsely
  1013.                   commented.  This  omission  has  been  rectified  by
  1014.                   copying all of the FIG listing comments,  plus  some
  1015.                   additional comments, into  the  MACRO-86  code.   In
  1016.                   addition, each entry in the dictionary has a comment
  1017.                   in the following form:
  1018.  
  1019.                   ;=AB  <name>   <description>   <stack effects>
  1020.  
  1021.                   where  A  is  a  letter  indicating  the   type   of
  1022.                   dictionary entry, and B is  a  character  indicating
  1023.                   whether the function has  been  added  or  modified.
  1024.                   This scheme  allows  automatic  glossary  generation
  1025.                   using a text editor or search utility.
  1026.  
  1027.           8086/8088 FIG-FORTH User's Guide                     Page 22
  1028.  
  1029.  
  1030.  
  1031.                   The dictionary entry types are:
  1032.  
  1033.                            C = code-level definition
  1034.                            : = colon definition
  1035.                            # = constant
  1036.                            ? = variable
  1037.                            U = user variable
  1038.  
  1039.                   The B character is either a blank,  a  plus,  or  an
  1040.                   asterisk;  indicating   that   the   definition   is
  1041.                   unmodified, added, or modified, respectively. 
  1042.  
  1043.  
  1044.           5.2  Modifications
  1045.  
  1046.                   The changes to the FIG listing fall  basically  into
  1047.                   two  categories:  changes  to  clean  up  the   disk
  1048.                   interface and manage buffers more  efficiently,  and
  1049.                   changes to route the i/o functions through execution
  1050.                   vectors.   The  sections  below  describe   specific
  1051.                   changes to the FIG model.  Each section  corresponds
  1052.                   to one in the FIG-FORTH  installation  manual.   Any
  1053.                   changes to that part of the model are listed there. 
  1054.  
  1055.  
  1056.           5.2.1  Boot Parameters
  1057.  
  1058.                        BSIN was changed to 127 - ASCII DEL. 
  1059.  
  1060.  
  1061.           5.2.2  Machine Code Definitions
  1062.  
  1063.                        Code added to  (FIND)  to  handle  word-aligned
  1064.                   definitions.  May be disabled by setting the  option
  1065.                   ALIGN to FALSE. 
  1066.  
  1067.  
  1068.           5.2.3  High-Level Utility Definitions
  1069.  
  1070.                        1+ and 2+ were changed to code definitions. 
  1071.                        TRAVERSE was modified  to  handle  word-aligned
  1072.                   LFA's. 
  1073.                        PFA was changed to handle word-aligned PFA's. 
  1074.                        EXPECT backspace was made destructive. 
  1075.                        ID.   was  modified  to  reset  MSB   of   last
  1076.                   character. 
  1077.                        CREATE  can  compile  dictionary  headers  with
  1078.                   word-aligned LFA's.  If DP is  odd  after  compiling
  1079.                   the name field, DP is incremented so that  the  rest
  1080.                   of the definition lies is word addressable.  If byte
  1081.                   values such as character  strings  are  subsequently
  1082.                   compiled into the definition, the alignment  may  be
  1083.                   lost.  Note that the length byte at NFA still  gives
  1084.                   the exact length of the name,  but  not  necessarily
  1085.                   the displacement to the LFA.  The alignment  may  be
  1086.  
  1087.           8086/8088 FIG-FORTH User's Guide                     Page 23
  1088.  
  1089.  
  1090.  
  1091.                   disabled by setting the ALIGN  option  to  FALSE  at
  1092.                   assembly time to save space. 
  1093.                        QUIT prints lower case "ok". 
  1094.                        ABORT prints the user version as well. 
  1095.                        COLD sets execution vectors. 
  1096.                        All system dependent  initialization  is  in  a
  1097.                   subroutine called SYSINIT, located in  4TH-SYSD.ASM,
  1098.                   which is called just prior  to  starting  the  inner
  1099.                   interpreter. 
  1100.  
  1101.  
  1102.           5.2.4  Installation Dependent Code
  1103.  
  1104.  
  1105.  
  1106.           5.2.4.1  Console I/O
  1107.  
  1108.                        KEY, EMIT, and  CR  were  changed  to  use  the
  1109.                   execution vectors @KEY, @EMIT, and @CR respectively.
  1110.                   These vectors are initialized to the CFA's of (KEY),
  1111.                   (EMIT) and (CR); but may be changed by  storing  new
  1112.                   CFA's in the vectors. 
  1113.                        Two options in 4TH-OPTS.H affect  console  i/o:
  1114.                   DIRECTCON and IOBITS.  If DIRECTCON is TRUE, console
  1115.                   i/o is performed by MS-DOS function six  and  seven,
  1116.                   which ignore all special characters.  Thus,  if  you
  1117.                   have an application which has to respond to ^P,  for
  1118.                   example, you should re-assemble with  DIRECTCON  set
  1119.                   to TRUE.  IOBITS is an equate which  determines  how
  1120.                   many bits to send/receive.  Normal  ASCII  terminals
  1121.                   don't use  the  MSB,  so  IOBITS  should  be  seven.
  1122.                   However, the IBM-PC uses all eight bits,  so  IOBITS
  1123.                   should  be  eight.   DIRECTCON  also   disables   ^C
  1124.                   interrupts, except during printer output. 
  1125.  
  1126.  
  1127.           5.2.4.2  Printer I/O
  1128.  
  1129.                        The variable  controlling  printer  output  was
  1130.                   changed to PRINTER.  If PRINTER is zero, no  printer
  1131.                   output occurs.  If PRINTER is positive, all  console
  1132.                   output also goes to  the  printer.   If  PRINTER  is
  1133.                   negative, output normally going to  the  console  is
  1134.                   sent only to the printer. 
  1135.  
  1136.  
  1137.           5.2.4.3  Disk I/O
  1138.  
  1139.                        The code to interface to the disk was  factored
  1140.                   into two parts.  All functions that  know  something
  1141.                   about the physical characteristics of the  disk  are
  1142.                   in the  4TH-DISK.ASM  file.   Every  other  function
  1143.                   knows only that disk blocks  are  1024  bytes  long.
  1144.                   This means that BLOCK-READ/WRITE must always deliver
  1145.                   1024 bytes and not one physical sector. 
  1146.  
  1147.           8086/8088 FIG-FORTH User's Guide                     Page 24
  1148.  
  1149.  
  1150.  
  1151.                        The  disk  read/write   routines   (BLOCK-READ,
  1152.                   BLOCK-WRITE)  were  changed  to  use  the  execution
  1153.                   vectors @BLKRD and @BLKWRT.  For normal  FORTH  disk
  1154.                   i/o, @BLKRD and @BLKWRT point to BLKRD  and  BLKWRT.
  1155.                   For screen file access, these  vectors  are  set  to
  1156.                   /BLOCK-READ and /BLOCK-WRITE. 
  1157.                        The variables DRIVE, RECORD,  REC/BLK  and  DTA
  1158.                   are set to the parameters used for each disk  access
  1159.                   and  may  be  examined  if  an  error  occurs.   The
  1160.                   variable DISK-ERROR is set to indicate  the  success
  1161.                   or failure of each disk operation.  If DISK-ERROR is
  1162.                   zero,  the  operation  was  successful.    Otherwise
  1163.                   DISK-ERROR has the MS-DOS error code as described in
  1164.                   its documentation,  except  that  write  errors  are
  1165.                   converted to negative numbers. 
  1166.                        The  buffer   management   was   also   changed
  1167.                   slightly.  When BUFFER has to flush a dirty block to
  1168.                   the disk, it checks and flushes ALL  dirty  buffers.
  1169.                   This requires very little additional  overhead,  and
  1170.                   it is  much  more  efficient  for  copying  multiple
  1171.                   blocks. 
  1172.  
  1173.           5.2.5  High-Level Definitions
  1174.  
  1175.           5.2.6  System Tools
  1176.  
  1177.           5.2.7  RAM Workspace
  1178.  
  1179.  
  1180.           5.2.8  Memory Map
  1181.  
  1182.                        The memory map was  extended  to  use  all  64K
  1183.                   (LIMIT=0), and 8 1K byte block buffers. 
  1184.  
  1185.  
  1186.           5.2.9  Other
  1187.  
  1188.                        COLD  sets  the  ^C  interrupt  vector  to  the
  1189.                   address of  a  code  fragment  which,  on  receiving
  1190.                   control after you  hit  ^C,  examines  the  variable
  1191.                   @BREAK.  If @BREAK is zero,  the  interrupt  handler
  1192.                   simply returns  from  the  interrupt  and  execution
  1193.                   continues.  Unfortunately, a "^C" is always sent  to
  1194.                   the console, and the key is not passed to FORTH.  If
  1195.                   @BREAK is non-zero, the  interrupt  handler  vectors
  1196.                   the inner interpreter to the (presumed CFA)  address
  1197.                   in @BREAK.  @BREAK is set at assembly  time  to  the
  1198.                   CFA of (ABORT), it is not initialized by  COLD.   If
  1199.                   the DIRECTCON option  is  selected,  almost  all  ^C
  1200.                   processing  is  disabled.   The  only  time   a   ^C
  1201.                   interrupt can occur is during printer output. 
  1202.                        BYE exits via INT 20H
  1203.  
  1204.           8086/8088 FIG-FORTH User's Guide                     Page 25
  1205.  
  1206.  
  1207.  
  1208.           5.3  Additions
  1209.  
  1210.                   Two new features have been added in this version  of
  1211.                   FIG FORTH.   Command  line  argument  interpretation
  1212.                   allows  you  to  pass  instructions  to  FORTH  from
  1213.                   COMMAND.  Thus, you can run FORTH from a batch  file
  1214.                   if the program doesn't require any  terminal  input.
  1215.                   The file interface allows FORTH to share information
  1216.                   with other MS-DOS programs and utilities. 
  1217.  
  1218.  
  1219.           5.3.1  Command Line Interpretation
  1220.  
  1221.                   When FORTH starts execution, it copys any string  of
  1222.                   text on the  command  line  to  the  terminal  input
  1223.                   buffer, and interprets it just as if you  had  typed
  1224.                   it. 
  1225.  
  1226.  
  1227.           5.3.2  File Interface
  1228.  
  1229.                   The goal in developing the  file  interface  was  to
  1230.                   allow FORTH  useful  access  to  MS-DOS  files,  not
  1231.                   simply the random access  screens.   The  constraint
  1232.                   was that it had to be accomplished with a minimum of
  1233.                   change to the FIG model.  This discussion is not  as
  1234.                   complete as it could be.  The  reason  for  this  is
  1235.                   that the details will probably  change.   While  the
  1236.                   overall design is (hopefully) sound, the fine points
  1237.                   are not completely worked out.  As they are applied,
  1238.                   they will certainly be improved. 
  1239.  
  1240.                   There are two parts to the file interface:  the  low
  1241.                   level functions defined in 4TH-FILE.ASM and the high
  1242.                   level words in FILES.SCR.  The  low-level  functions
  1243.                   are little more  than  MS-DOS  function  calls  with
  1244.                   FORTH headers.  The high-level definitions  do  most
  1245.                   of  the  work,  making  it  easier  to  modify   the
  1246.                   interface. 
  1247.  
  1248.                   The words defined in FILES.SCR allow you  to  define
  1249.                   files in much the same  way  you  define  variables.
  1250.                   After a file has been defined, the name is  used  to
  1251.                   refer to it.  The name acts just  like  a  variable,
  1252.                   returning an address.  The  address  returned  is  a
  1253.                   pointer to the file header and file  control  block,
  1254.                   or FCB.  The header is a  word  of  data  where  the
  1255.                   file's attributes are kept, this header  address  is
  1256.                   referred to as the file descriptor,  or  FD.   These
  1257.                   attributes are only used by FORTH, MS-DOS never sees
  1258.                   them.  At present, the only  attributes  are:  read,
  1259.                   write, sequential/random access and open.  Following
  1260.                   the header is the FCB which MS-DOS  uses  while  the
  1261.                   file is open. 
  1262.  
  1263.           8086/8088 FIG-FORTH User's Guide                     Page 26
  1264.  
  1265.  
  1266.  
  1267.                   The first part of the FCB is the filespec.  This  is
  1268.                   the drive, filename and extension for the file,  and
  1269.                   is the name by which  MS-DOS  refers  to  the  file.
  1270.                   Before opening a file, these fields must  be  filled
  1271.                   in.  Assigning the filename is accomplished  by  two
  1272.                   methods, one for interactive use  and  one  for  use
  1273.                   inside definitions.  The word FNAME takes  a  target
  1274.                   address and a mode number on  the  stack.   It  then
  1275.                   parses the string at PAD (actually PAD+1, PAD  holds
  1276.                   the count byte), and returns a flag which is true if
  1277.                   the filename was ambiguous.  If FNAME finds that the
  1278.                   given filename is illegal (or  null)  it  prints  an
  1279.                   error and aborts. 
  1280.  
  1281.                   To assign a filename to a file  from  the  terminal,
  1282.                   the word /IS" is provided.  This function  takes  an
  1283.                   fd off the stack and assigns the following  word  in
  1284.                   the input stream as the filename.  The /IS" function
  1285.                   can be used in a definition, but it can't be used to
  1286.                   assign a filename to a file without console input. 
  1287.  
  1288.                   Once the file has been defined, and has a  name,  it
  1289.                   can be opened or created using  /OPEN,  or  /CREATE.
  1290.                   The file can be closed using /CLOSE. 
  1291.  
  1292.                   For character files, /GETC and /PUTC are provided to
  1293.                   read/write  one  character;  and  /READ  and  /WRITE
  1294.                   transfer a number of bytes at  once.   Screen  files
  1295.                   use /BLOCK-READ and /BLOCK-WRITE.   These  functions
  1296.                   are  called   indirectly   through   BLOCK-READ   or
  1297.                   BLOCK-WRITE. 
  1298.  
  1299.                   This  reference  is  admittedly   incomplete.    For
  1300.                   further information, study the glossary for 4TH-FILE
  1301.                   and the FORTH code for the file interface.
  1302.  
  1303.           8086/8088 FIG-FORTH User's Guide                     Page 27
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.           6.0  Glossary
  1310.  
  1311.                   This  section  is  a  glossary  of  words  added  or
  1312.                   changed, relative to FIG-FORTH v1.0.   The  name  of
  1313.                   the word is given,  then its stack effects, then the
  1314.                   type of definition, where the letter  indicates  the
  1315.                   type of definition:
  1316.  
  1317.                            C = code-level definition
  1318.                            : = colon definition
  1319.                            # = constant
  1320.                            ? = variable
  1321.                            U = user variable
  1322.  
  1323.                   and  the  second  letter   indicates   whether   the
  1324.                   definition was added  (+)  or  modified  (*).   And,
  1325.                   finally, the file where the word is defined. 
  1326.  
  1327.           8086/8088 FIG-FORTH User's Guide                     Page 28
  1328.  
  1329.  
  1330.  
  1331.  
  1332.  
  1333.           6.1  Assembly Listing Definitions
  1334.  
  1335.                   (2ARR)           n1 n2 PFA -- addr               C+ XTNS
  1336.                                   Two dimensional word array primitive
  1337.                   compiled  by  2ARRAY.   The  address  of  the  array
  1338.                   element at row n1, column n2, of an array  beginning
  1339.                   at addr+4 is left on the stack.  It is assumed  that
  1340.                   the number  of  columns  is  stored  at  addr.   The
  1341.                   contents of addr+2 could hold  the  number  of  rows
  1342.                   (perhaps for error checking), but it isn't  used  in
  1343.                   the calculation. 
  1344.  
  1345.                   (2CARR)          n1 n2 PFA -- addr2              C+ XTNS
  1346.                                   Two dimensional byte array primitive
  1347.                   compiled by  STRINGS.   The  address  of  the  array
  1348.                   element at row n1, column n2 of an  array  beginning
  1349.                   at PFA+4 is left on the stack.  It is  assumed  that
  1350.                   the row size is at PFA.  The contents of PFA+2 could
  1351.                   hold the number of rows, but it isn't  used  in  the
  1352.                   calculations. 
  1353.  
  1354.                   (ARRAY)          n PFA -- addr                   C+ XTNS
  1355.                                   Integer  array  primitive  used   by
  1356.                   ARRAY.  The address of the nth element of the  array
  1357.                   beginning at PFA+2 is calculated  and  left  on  the
  1358.                   stack.  The length of the array is stored at PFA. 
  1359.  
  1360.                   (BLKRD)          --                              C+ DISK
  1361.                                   Block  read  primitive   called   by
  1362.                   BLKRD.  This function calls the absolute  disk  read
  1363.                   function (INT 25) to access the disk.  This function
  1364.                   transfers REC/BLK records,  starting  at  RECORD  on
  1365.                   DRIVE to DTA.  The code returned by the interrupt is
  1366.                   placed in DISK-ERROR, zero indicating success. 
  1367.  
  1368.                   (BLKWRT)         --                              C+ DISK
  1369.                                   Block  write  primitive  called   by
  1370.                   BLKWRT.  This function transfers REC/BLK records  on
  1371.                   DRIVE starting at RECORD to DTA.   The  return  code
  1372.                   from INT 26H is negated and  placed  in  DISK-ERROR,
  1373.                   zero means success. 
  1374.  
  1375.                   (CARR)           n PFA -- addr                   C+ XTNS
  1376.                                   Byte  array  primitive  compiled  by
  1377.                   CARRAY.  The address of the  nth  character  in  the
  1378.                   array beginning at PFA+2 is calculated and  left  on
  1379.                   the stack.  The length of the array or  the  current
  1380.                   length of the string may be left at PFA.
  1381.  
  1382.           8086/8088 FIG-FORTH User's Guide                     Page 29
  1383.  
  1384.  
  1385.  
  1386.                   (CLOSE)          FCB -- f                        C+ FILE
  1387.                                   Primitive  function  to  close   FCB
  1388.                   using  DOS  function  10H.   The  flag  is  zero  if
  1389.                   successful, 0FFH if not. 
  1390.  
  1391.                   (CREATE)         FCB -- f                        C+ FILE
  1392.                                   Create and open a file as  specified
  1393.                   in FCB using DOS function 16H.  The flag returned is
  1394.                   zero if successful, 0FFH if not. 
  1395.  
  1396.                   (FBLKRD)         FCB n -- f                      C+ FILE
  1397.                                   File  block  read  primitive.   This
  1398.                   function reads n  blocks  from  an  open  FCB.   The
  1399.                   blocks read are the size  specified  in  the  record
  1400.                   size field of the FCB.  For normal screen  files,  n
  1401.                   is always 1 and the  record  size  is  set  to  1024
  1402.                   bytes. 
  1403.  
  1404.                   (FBLKWRT)        FCB n -- f                      C+ FILE
  1405.                                   Write n blocks to the file specified
  1406.                   by FCB.  See (FBLKRD) above. 
  1407.  
  1408.                   (FIND)           a1 NFA -- [PFA b] f             C* MAIN
  1409.                                   (FIND)  was   modified   to   handle
  1410.                   aligned  dictionary  headers  (only  when  ALIGN  is
  1411.                   true).  The address list  following  the  header  is
  1412.                   aligned by inserting a  NOP  (90H)  after  the  last
  1413.                   character of the name field.  (FIND) must take  this
  1414.                   into account when looking up a name. 
  1415.  
  1416.                   (FNAME)          FCB addr1 n -- addr2 f          C+ FILE
  1417.                                   Parse  the  string  at  addr1  as  a
  1418.                   filename using mode n, and assign it  to  FCB.   The
  1419.                   first character not parsed and an ambiguous filename
  1420.                   are left on  the  stack.   This  function  uses  DOS
  1421.                   function 29H, which defines the modes. 
  1422.  
  1423.                   (OPEN)           FCB -- f                        C+ FILE
  1424.                                   Open the specified  FCB.   The  flag
  1425.                   returns the success or  failure  of  the  operation:
  1426.                   zero if successful, 0FFH otherwise. 
  1427.  
  1428.                   (READ)           FCB addr -- f                   C+ FILE
  1429.                                   Sequential      read      primitive.
  1430.                   Transfers the next record in the file  specified  by
  1431.                   FCB  to  addr.   The  status  of  the  operation  is
  1432.                   returned in  the  flag  f.   The  flag  is  zero  if
  1433.                   successful, 0FF if not. 
  1434.  
  1435.                   (WRITE)          FCB addr -- f                   C+ FILE
  1436.                                   Sequential write primitive.   Writes
  1437.                   the next record of the file specified  by  FCB  from
  1438.                   addr.  The flag returned by DOS function 15H is left
  1439.                   on the stack. 
  1440.  
  1441.           8086/8088 FIG-FORTH User's Guide                     Page 30
  1442.  
  1443.  
  1444.  
  1445.                   (XOF)                    n1 n2 -- [n1]           C+ XTNS
  1446.                                   Control structure primitive compiled
  1447.                   by OF.  If the case being scanned for  (n1)  matches
  1448.                   the current case (n2), the tag n1 is dropped and the
  1449.                   FORTH words following the branch compiled by OF  are
  1450.                   executed.  If the case tags don't match, n1 is  left
  1451.                   on the stack and the branch is executed to check the
  1452.                   next case. 
  1453.  
  1454.                   +BUF             addr1 -- addr2                  :* MAIN
  1455.                                   Advance the buffer pointer addr1  to
  1456.                   the next buffer at addr2. 
  1457.  
  1458.                   1-               n -- n-1                        C+ MAIN
  1459.                                   Subtract one from the item on top of
  1460.                   the stack. 
  1461.  
  1462.                   2-               n -- n-2                        C+ MAIN
  1463.                                   Subtract two from the item on top of
  1464.                   the stack. 
  1465.  
  1466.                   ?FIRST           FCB addr -- f                   C+ FILE
  1467.                                   Search the disk  directory  for  the
  1468.                   first occurance of FCB.  The flag returned  is  zero
  1469.                   if none are found, 0FF otherwise.   If  a  match  is
  1470.                   found, its directory entry is placed at addr. 
  1471.  
  1472.                   ?NEXT            addr FCB -- f                   C+ FILE
  1473.                                   Search for  the  next  occurance  of
  1474.                   FCB.  The search FCB must previously have  been  set
  1475.                   up by ?FIRST.  If a match is found, f will  be  0FFH
  1476.                   and the matching directory entry  will  be  left  at
  1477.                   addr. 
  1478.  
  1479.                   @BLKRD           - addr                          U+ MAIN
  1480.                                   Execution vector holding the CFA  of
  1481.                   a function to read one block from  the  disk.   This
  1482.                   vector is either BLKRD  for  FORTH  disk  access  or
  1483.                   FBLKRD for screen file access.  BLOCK-READ uses this
  1484.                   vector. 
  1485.  
  1486.                   @BLKWRT          - addr                          U+ MAIN
  1487.                                   Execution vector holding the CFA  of
  1488.                   a function to write one block  to  the  disk.   This
  1489.                   vector is either BLKWRT for  FORTH  disk  access  or
  1490.                   FBLKWRT for screen file  access.   BLOCK-WRITE  uses
  1491.                   this vector. 
  1492.  
  1493.                   @BREAK           -- addr                                 ?+ SYSD
  1494.                                   Execution vector holding the CFA  of
  1495.                   the function to be executed on input if  a  ^C.   If
  1496.                   @BREAK  is  zero,  the  interrupt   handler   simply
  1497.                   returns, effectively ignoring the interrupt.
  1498.  
  1499.           8086/8088 FIG-FORTH User's Guide                     Page 31
  1500.  
  1501.  
  1502.  
  1503.                   @CR              -- addr                                 U+ MAIN
  1504.                                   Execution   vector   to   output   a
  1505.                   newline,  usually  carriage  return/linefeed.   COLD
  1506.                   initializes @CR to the CFA of (CR). 
  1507.  
  1508.                   @EMIT            -- addr                                 U+ MAIN
  1509.                                   Execution  vector  to  do  character
  1510.                   output.  Initialized by COLD to the CFA of (EMIT). 
  1511.  
  1512.                   @KEY             -- addr                                 U+ MAIN
  1513.                                   Execution  vector  to  do  character
  1514.                   input.  Initialized by COLD to the CFA of (KEY). 
  1515.  
  1516.                   B/SEC            -- n                            C+ FILE
  1517.                                   Calls DOS function 1BH  and  returns
  1518.                   the number of bytes per physical disk sector. 
  1519.  
  1520.                   BLK/DRIVE        -- n                            #+ DISK
  1521.                                   Constant returning the number of  1K
  1522.                   disk blocks per drive. 
  1523.  
  1524.                   BLKRD            addr blk --                     :+ DISK
  1525.                                   This function  reads  block  blk  to
  1526.                   addr.  This is basically an  interface  between  the
  1527.                   BLOCK-READ function and the (BLKRD) functions. 
  1528.  
  1529.                   BLKWRT           addr blk --                     :+ DISK
  1530.                                   This function writes block blk  from
  1531.                   addr.  This is basically an  interface  between  the
  1532.                   BLOCK-WRITE function and the (BLKWRT) functions. 
  1533.  
  1534.                   BLOCK            n -- addr                       :* MAIN
  1535.                                   BLOCK was modified to  check  for  a
  1536.                   disk error. 
  1537.  
  1538.                   BLOCK-READ       addr blk --                     :+ MAIN
  1539.                                   Read one block to addr.   Calls  the
  1540.                   function whose CFA is in @BLKRD  to  do  the  actual
  1541.                   transfer. 
  1542.  
  1543.                   BLOCK-WRITE      addr blk --                     :+ MAIN
  1544.                                   Write one block  from  addr.   Calls
  1545.                   the function whose CFA  is  in  @BLKWRT  to  do  the
  1546.                   actual transfer. 
  1547.  
  1548.                   BUFFER           n -- addr                       :* MAIN
  1549.                                   This function was modified to  flush
  1550.                   all dirty buffers when one is found. 
  1551.  
  1552.                   COLD             --                              :* MAIN
  1553.                                   Added code to  initialize  execution
  1554.                   vectors.
  1555.  
  1556.           8086/8088 FIG-FORTH User's Guide                     Page 32
  1557.  
  1558.  
  1559.  
  1560.                   CR               --                              :* MAIN
  1561.                                   Output a carriage return/linefeed by
  1562.                   calling the function whose CFA is in @CR. 
  1563.  
  1564.                   CREATE           --                              :* MAIN
  1565.                                   Create a dictionary header  for  the
  1566.                   next word in the input stream.  CREATE was  modified
  1567.                   to align the address list.  The ALIGN option must be
  1568.                   selected for this to occur. 
  1569.  
  1570.                   D&RCALC          n --                            :+ DISK
  1571.                                   Set DRIVE and RECORD  for  block  n.
  1572.                   This function is called by BLKRD/BLKWRT  to  set  up
  1573.                   for (BLKRD)/(BLKWRT). 
  1574.  
  1575.                   DATE!            n1 n2 n3 --                     C+ XTNS
  1576.                                   Date set operator.   The  parameters
  1577.                   are  n1=month,  n2=day,  n3=year.   If  any  of  the
  1578.                   parameters are out of range, no change is made. 
  1579.  
  1580.                   DATE@            -- n1 n2 n3                     C+ XTNS
  1581.                                   Date fetch operator.  The parameters
  1582.                   are  n1=month,  n2=day,  n3=year.   If  any  of  the
  1583.                   parameters are out of range, no change is made. 
  1584.  
  1585.                   DISK             n -- n2                                 C+ FILE
  1586.                                   Set the current default drive to  n.
  1587.                   Drive A is zero, B is one.  The  number  of  drives,
  1588.                   n2, is left on the stack. 
  1589.  
  1590.                   DISK@            -- n                            C+ FILE
  1591.                                   Return  the  current  default  drive
  1592.                   number. 
  1593.  
  1594.                   DTA              -- addr                                 ?+ MAIN
  1595.                                   Variable holding the address of  the
  1596.                   last disk transfer operation.  This variable is  set
  1597.                   by R/W for use by the transfer functions. 
  1598.  
  1599.                   EMIT             c --                            :* MAIN
  1600.                                   Function  to  do  character  output.
  1601.                   Calls the function whose CFA is in @EMIT to  do  the
  1602.                   actual output. 
  1603.  
  1604.                   EMPTY-BUFFERS    --                              :* MAIN
  1605.                                   This function was  modified  to  set
  1606.                   emptied buffers to block 32767.  FIG-FORTH set  them
  1607.                   to zero. 
  1608.  
  1609.                   FLUSH            --                              :* MAIN
  1610.                                   FLUSH  was  also  modified  so  that
  1611.                   empty buffers are assigned to block 32767.
  1612.  
  1613.           8086/8088 FIG-FORTH User's Guide                     Page 33
  1614.  
  1615.  
  1616.  
  1617.                   FDEL             FCB -- f                        C+ FILE
  1618.                                   Delete the file  specified  by  FCB.
  1619.                   The  flag  returned  is  zero  if  successful,  0FFH
  1620.                   otherwise. 
  1621.  
  1622.                   FREN             addr -- f                       C+ FILE
  1623.                                   Rename the  file  according  to  the
  1624.                   special FCB at addr.  See the DOS function  17H  for
  1625.                   details on how this is set up. 
  1626.  
  1627.                   KEY              -- c                            :+ MAIN
  1628.                                   Character input function.  KEY calls
  1629.                   the function  whose  CFA  is  in  @KEY  to  get  the
  1630.                   character. 
  1631.  
  1632.                   L!               n seg off --                    C+ XTNS
  1633.                   L@               seg off -- n                    C+ XTNS
  1634.                   LC!              n seg off --                    C+ XTNS
  1635.                   LC@              seg off -- b                    C+ XTNS
  1636.                                   Intersegment fetch/store  operators.
  1637.                   These are similar to  the  usual  FORTH  fetch/store
  1638.                   words, except they use a double-word address.   Note
  1639.                   that   the    absolute    location    accessed    is
  1640.                   seg*16+offset. 
  1641.  
  1642.                   MAXBLOCK         -- n                            #+ DISK
  1643.                                   Constant returning the highest legal
  1644.                   block number.  That is, BLK/DRIVE*(MAXDRIVE+1)-1. 
  1645.  
  1646.                   MAXDRIVE         -- n                            #+ DISK
  1647.                                   Constant returning the highest legal
  1648.                   drive number. 
  1649.  
  1650.                   MYSEG            -- seg                          C+ MYSEG
  1651.                                   This  word  returns  the  value   of
  1652.                   FORTH's  current  segment.   This  allows  the  long
  1653.                   fetch/store operators  to  access  locations  inside
  1654.                   FORTH easily. 
  1655.  
  1656.                   NFA              PFA -- NFA                      :* MAIN
  1657.                   PFA              NFA -- PFA                      :* MAIN
  1658.                                   These  functions  can   adjust   for
  1659.                   aligned definitions, if  ALIGN  is  selected  during
  1660.                   assembly. 
  1661.  
  1662.                   PRINTER          -- addr                                 ?+ MAIN
  1663.                                   Flag controlling printer output.  If
  1664.                   PRINTER is zero, nothing is sent to the printer.  If
  1665.                   PRINTER is positive, output to the console also goes
  1666.                   to the printer.   If  PRINTER  is  negative,  output
  1667.                   normally going to the console will be  sent  to  the
  1668.                   printer only.  Note that this is independent of  the
  1669.                   ^P/^N printer echo!
  1670.  
  1671.           8086/8088 FIG-FORTH User's Guide                     Page 34
  1672.  
  1673.  
  1674.  
  1675.                   R/W              addr blk f --                   :* MAIN
  1676.                                   This function was modified to simply
  1677.                   pass the addr  and  blk  on  to  the  BLOCK-READ  or
  1678.                   BLOCK-WRITE functions. 
  1679.  
  1680.                   REC/BLK          -- n                            #+ DISK
  1681.                                   Constant  returning  the  number  of
  1682.                   disk records required to fill one 1024 byte  buffer.
  1683.                   All disk accesses look to FORTH like  they  transfer
  1684.                   1K of data. 
  1685.  
  1686.                   RECORD           -- addr                                 ?+ MAIN
  1687.                                   Variable  holding  the  disk  record
  1688.                   number where the last block  accessed  began.   That
  1689.                   is, if the last block accessed was  2,  then  record
  1690.                   would contain 2*REC/BLK.  This variable  is  set  by
  1691.                   D&RCALC for use by (BLKRD)/(BLKWRT). 
  1692.  
  1693.                   SAVBUF           addr --                                 :+ MAIN
  1694.                                   This function saves  the  buffer  at
  1695.                   addr if it has been updated.  The buffer is  flushed
  1696.                   but not emptied. 
  1697.  
  1698.                   SAVE-BUFFERS     --                              :+ MAIN
  1699.                                   This  function   flushes   all   the
  1700.                   buffers but doesn't  empty  them.   SAVE-BUFFERS  is
  1701.                   called by BUFFER when it finds a dirty buffer. 
  1702.  
  1703.                   TIME!            n1 n2 --                        C+ XTNS
  1704.                   TIME@            -- n1 n2                        C+ XTNS
  1705.                                   Set/fetch  the  system  time.    The
  1706.                   parameters  are  n1=[sec/csec],  n2=[hr/min];   each
  1707.                   quantity is a byte, but the four are packed  into  2
  1708.                   words.  Note that the low byte of the top stack item
  1709.                   has the minutes, the high byte holds the hours,  and
  1710.                   so on.  If any of the parameters are out  of  range,
  1711.                   there is no effect.
  1712.  
  1713.           8086/8088 FIG-FORTH User's Guide                     Page 35
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.           6.2  Deleted Definitions
  1720.  
  1721.                   The  following  words  were  deleted  from  the  FIG
  1722.                   listing:
  1723.  
  1724.                            EPRINT
  1725.                            SEC
  1726.                            SECRD
  1727.                            SECWT
  1728.                            SET-DRIVE
  1729.                            SET-IO
  1730.                            T&SCALC
  1731.                            TRACK
  1732.  
  1733.           8086/8088 FIG-FORTH User's Guide                     Page 36
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.           6.3  High-level Extensions
  1740.  
  1741.                   The following words were added  by  compiling  FORTH
  1742.                   screens and saving the new version  of  FORTH.   The
  1743.                   FORTH source is included in the screen files. 
  1744.  
  1745.                   ARRAY            n --                            :+ ARRAYS.SCR
  1746.                   2ARRAY           n1 n2 --                        :+ ARRAYS.SCR
  1747.                                   One  and  two  dimensional   integer
  1748.                   array defining words.  Used as:
  1749.  
  1750.                            3 10 ARRAY WEIGHTS
  1751.  
  1752.                   to define a 3 by 10 array of integers which  can  be
  1753.                   accessed by:
  1754.  
  1755.                            0 0 WEIGHTS @  2 9 WEIGHTS ! 
  1756.  
  1757.                   Which would replace the last element by the first. 
  1758.  
  1759.                   STRING           n --                            :+ ARRAYS.SCR
  1760.                   STRINGS          n1 n2 --                        :+ ARRAYS.SCR
  1761.                                   One and two dimensional  byte  array
  1762.                   defining words.  Similar to  the  array  definitions
  1763.                   above, but are accessed by C@ and C!. 
  1764.  
  1765.                   CASE     OF ENDOF        ENDCASE                         :+ CASE.SCR
  1766.                                   These words add a case construct  to
  1767.                   FORTH.   They  have  been  documented   in   several
  1768.                   different places.  Quite a few examples are found in
  1769.                   the ASSEMBLER screens. 
  1770.  
  1771.                   DUMP             addr1 -- addr2                  :+ UTIL.SCR
  1772.                                   This word displays the  contents  of
  1773.                   memory from addr1 to addr2-1.  The address  left  on
  1774.                   the stack can be used to  continue  dumping  without
  1775.                   having to keep track of the address.   The  dump  is
  1776.                   given in the current number base.  A variable  named
  1777.                   SEGMENT is used as the base, with addr1  then  being
  1778.                   an offset in that segment.  SEGMENT  is  initialized
  1779.                   to MYSEG. 
  1780.  
  1781.                   NEW              --                              :+ UTIL.SCR
  1782.                                   NEW updates the start-up  parameters
  1783.                   to reflect the current state of FORTH.  This  allows
  1784.                   compiled definitions to be  retained  when  COLD  is
  1785.                   executed.  Note that if you FORGET the  added  words
  1786.                   after executing NEW, the start-up parameters will be
  1787.                   wrong, and NEW must  be  run  again  before  a  cold
  1788.                   start.
  1789.           8086/8088 FIG-FORTH User's Guide                     Page 37
  1790.  
  1791.  
  1792.  
  1793.                   SIZE?            --                              :+ UTIL.SCR
  1794.                                   Shows the current size of the  FORTH
  1795.                   dictionary, and the free space remaining.   This  is
  1796.                   primarily useful for saving modified FORTHs.
  1797.           8086/8088 FIG-FORTH User's Guide                     Page 38
  1798.  
  1799.  
  1800.  
  1801.  
  1802.  
  1803.           7.0  Future Extensions
  1804.  
  1805.                   This version includes almost all of the extensions I
  1806.                   had planned to implement in the "immediate  future".
  1807.                   It will be work enough fixing bugs  and  tuning  the
  1808.                   revisions in  this  package,  without  shooting  for
  1809.                   major revisions. 
  1810.  
  1811.                   But, my list for  the  questionable  future  remains
  1812.                   intact:
  1813.  
  1814.                            Cross/target compiler
  1815.                            Code level floating point/8087 support
  1816.                            Multisegmented > 64K
  1817.                            Multitasking
  1818.                            Tree structured vocabularies/file system
  1819.                            High-level interrupt handling
  1820.  
  1821.                   Should any of  these  interest  you,  or  spark  any
  1822.                   comments,  I  would  be  happy  to  talk  or  trade.
  1823.                   Specifically, I would really love to have some  kind
  1824.                   of floating point package: this is  my  last  excuse
  1825.                   for writing ANYTHING in BASIC! 
  1826.  
  1827.                   The MACRO-86 assembler is really cumbersome at  this
  1828.                   kind of work, and FORTH is ideally suited to writing
  1829.                   new FORTHs.  If I  can  get  metaFORTH  going,  that
  1830.                   would make a nice project.
  1831.           8086/8088 FIG-FORTH User's Guide                     Page 39
  1832.  
  1833.  
  1834.  
  1835.  
  1836.           8.0  FORTH Sources
  1837.  
  1838.                   The following are sources of  information  regarding
  1839.                   the implementation and use of FORTH. 
  1840.  
  1841.  
  1842.                 * STARTING FORTH, by Leo Brodie.  Prentice Hall 1981
  1843.                   This is  probably  the  best  introductory  book  on
  1844.                   FORTH. 
  1845.  
  1846.  
  1847.                 * Byte, vol.  5 no.  8, August 1980
  1848.                   This issue was devoted to FORTH, and  contains  good
  1849.                   discussions of defining words and FORTH internals. 
  1850.  
  1851.                 * Dr.  Dobb's Journal, vol.  6 no.  9, September 1980
  1852.                   Dr.  Dobb's Journal, vol.  7 no.  9, September 1981
  1853.                   These issues were both devoted to FORTH topics. 
  1854.  
  1855.                 * Various publications of the Forth Interest Group:
  1856.                   Fig  FORTH  Installation  Guide,  FORTH   DIMENSIONS
  1857.                   bi-monthly journal. 
  1858.  
  1859.                 * Mountain View Press
  1860.                   P.O.  Box 4656, Mountain View, CA 94040
  1861.                   (415) 961-4103
  1862.                   This company has a large selection of  software  and
  1863.                   publications for sale.
  1864.  
  1865.           8086/8088 FIG-FORTH User's Guide                     Page 40
  1866.  
  1867.  
  1868.  
  1869.  
  1870.  
  1871.                       Appendix A - Using Execution Vectors
  1872.  
  1873.  
  1874.  
  1875.           The i/o functions in this version of FORTH have been changed
  1876.           to use execution vectors.  An execution vector is  a  simple
  1877.           way to allow the user to substitute a different function for
  1878.           the function which is vectored in this way. 
  1879.  
  1880.  
  1881.           A.1  Concepts
  1882.  
  1883.           The way an execution vector works is quite simple.   If  you
  1884.           are familiar with the concept of pointers to data,  this  is
  1885.           nothing new, for execution  vectors  are  only  pointers  to
  1886.           functions.  The pointer may be changed to hold  the  address
  1887.           of any function, and  as  long  as  the  specified  function
  1888.           expects and returns the same parameters and result,  no  one
  1889.           knows the difference. 
  1890.  
  1891.           The FORTH interpreter functions on this principle: it inputs
  1892.           a word, looks it up in the dictionary, and executes it.  The
  1893.           interpreter can totally ignore the action taken by the words
  1894.           it executes.  In standard FORTH, the function which executes
  1895.           a word is called EXEC.  The address that EXEC expects on the
  1896.           stack differs between FORTHs.   In  FIG-FORTH,  the  address
  1897.           must be a Code Field Address, or CFA.  The address  returned
  1898.           by the dictionary search words ( ' and -FIND) is a Parameter
  1899.           Field Address (PFA).   Thus,  to  look  up  a  word  in  the
  1900.           dictionary, you can type
  1901.  
  1902.                    ' MY-WORD
  1903.  
  1904.           but to find and execute MY-WORD, you would type
  1905.  
  1906.                    ' MY-WORD CFA EXEC
  1907.  
  1908.           This is totally equivalent to just typing MY-WORD. 
  1909.  
  1910.           In  this  way,  any  function  can  be  vectored  through  a
  1911.           variable: the variable holds the CFA of the function  to  be
  1912.           executed.  Instead of executing the function  directly,  the
  1913.           variable is fetched and the CFA stored  there  is  executed.
  1914.           Now, instead of jumping  directly  to  code  which  sends  a
  1915.           character to the console, KEY fetches the variable @KEY, and
  1916.           does whatever is at that CFA.  The definition of KEY is thus
  1917.  
  1918.                    : KEY @KEY @ EXEC ;
  1919.  
  1920.           To change the function of KEY, you just  store  a  different
  1921.           CFA in @KEY.  The new function can be defined after KEY, and
  1922.           any function which uses KEY will now call the new  function.
  1923.           The  danger  here  should  be  obvious:  if  the  substitute
  1924.           8086/8088 FIG-FORTH User's Guide                     Page 41
  1925.           Appendix A - Using Execution Vectors
  1926.  
  1927.  
  1928.  
  1929.           function doesn't have the same stack effects as the standard
  1930.           function, FORTH is going to get really confused. 
  1931.  
  1932.  
  1933.           A.2  An Example
  1934.  
  1935.           Although this arrangement  is  slightly  more  complex,  the
  1936.           power and flexibility make it well worth the  extra  effort.
  1937.           The following example should make this clear. 
  1938.  
  1939.           Suppose you want to do all input in  capital  letters  only.
  1940.           You could write  your  own  specialized  input  routine,  or
  1941.           simply define an upper-case-only version of KEY and redirect
  1942.           KEY to that function.  Here is the definition  for  the  new
  1943.           KEY:
  1944.  
  1945.                    : UC-KEY
  1946.                         (KEY) DUP 96 > OVER 123 < AND
  1947.                         IF ( a-z )
  1948.                            32 -
  1949.                         THEN ;
  1950.  
  1951.           Now all you have  to  do  is  set  @KEY  to  point  to  your
  1952.           function:
  1953.  
  1954.                    ' UC-KEY CFA @KEY ! 
  1955.  
  1956.           and any lower case letter will be converted automatically to
  1957.           upper case.  To restore KEY to the original action,  restore
  1958.           @KEY to (KEY):
  1959.  
  1960.                    ' (KEY) CFA @KEY ! 
  1961.  
  1962.           Note that UC-KEY still calls (KEY)  to  get  the  character.
  1963.           While this is usually the case, it  is  not  necessary:  you
  1964.           could change KEY to get characters from any  source.   Also,
  1965.           be careful that you don't call the  vectored  function  from
  1966.           within your replacement.  If KEY had been  used  instead  of
  1967.           (KEY)  in  the  definition  above,  once   @KEY   had   been
  1968.           re-assigned you  would  have  a  good  example  of  infinite
  1969.           recursion!  Actually it isn't infinite - FORTH  dies  rather
  1970.           quickly... 
  1971.  
  1972.           This discussion applies to all  of  the  i/o  words,  except
  1973.           ?TERMINAL.  The block i/o functions are re-assigned in  this
  1974.           way to use the screen files.  There are more elegant ways of
  1975.           implementing execution vectors, which bypass  the  need  for
  1976.           separate variables, but  they  require  new  defining  words
  1977.           which  would  have  been  inconvenient  to  define  in   the
  1978.           assembler source.
  1979.           8086/8088 FIG-FORTH User's Guide                     Page 42
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.                         Appendix B - Building FORTH.COM
  1986.  
  1987.  
  1988.  
  1989.           The following example serves several  functions.   It  is  a
  1990.           real session with FORTH, it shows how the FORTH.COM file was
  1991.           constructed, and, it demonstrates how to modify and save new
  1992.           versions of FORTH. 
  1993.  
  1994.           After assembling the FORTH source, you are left with a  bare
  1995.           kernel.  To add the  utilities,  editor  and  file  handling
  1996.           functions, several things have to be done:
  1997.  
  1998.                1) The file interface screens must be transferred to  a
  1999.                   FORTH disk.  This process involves  using  DEBUG  to
  2000.                   load the file and write it to the FORTH disk. 
  2001.  
  2002.                2) The file interface is LOADed from the FORTH disk. 
  2003.  
  2004.                3) The utilities and editor  are  /LOAD"ed  from  their
  2005.                   files. 
  2006.  
  2007.                4) FORTH is reset to make the additions permanent,  and
  2008.                   the version number is changed. 
  2009.  
  2010.                5) The utilities for saving FORTH are loaded  and  used
  2011.                   to write the new FORTH to a .COM file. 
  2012.  
  2013.           The following session was  copied  from  a  listing  of  the
  2014.           commands to build FORTH.COM.   An  ellipsis  indicates  that
  2015.           part of the listing has been left out. 
  2016.  
  2017.           This example assumes that you have a FORTH disk in drive  A,
  2018.           and your FORTH system disk with  FORTH.COM  and  the  screen
  2019.           files in drive B. 
  2020.  
  2021.  
  2022.  
  2023.  
  2024.  
  2025.                    B:DEBUG FILES.SCR
  2026.                    -W 100 0 64 20
  2027.                    -Q
  2028.                    B:
  2029.  
  2030.           Here, DEBUG has loaded the MS-DOS file interface screens  in
  2031.           FILES.SCR and then written the screens to disk A starting at
  2032.           screen 100.  This assumes that one record holds one  screen.
  2033.           You will have to adjust the record numbers if  this  is  not
  2034.           the case.
  2035.           8086/8088 FIG-FORTH User's Guide                     Page 43
  2036.           Appendix B - Building FORTH.COM
  2037.  
  2038.  
  2039.  
  2040.                    B:4TH
  2041.  
  2042.                    8086 FIG-FORTH Version 1.0A
  2043.                    100 LOAD 102 LOAD BYE MSG # 4 ok
  2044.                    LATEST ID.  LOAD" ok
  2045.  
  2046.           After assembling FORTH and grabbing a snack while MASM chugs
  2047.           along, the resulting 4TH.COM is started.  The  newly  copied
  2048.           screens residing on disk A are loaded,  the  last  word  now
  2049.           being LOAD". 
  2050.  
  2051.  
  2052.  
  2053.  
  2054.  
  2055.                    USING" FUTIL" last block in B:FUTIL.SCR is 10 ok
  2056.                    1 LOAD ok
  2057.                    2 LOAD ok
  2058.                    3 LOAD .DIR MSG # 4 ok
  2059.                    7 LOAD ok
  2060.                    LATEST ID.  COPY>SCR ok
  2061.                    EOF B:FUTIL .SCR 11264 07-19-1983 2:37 ok
  2062.  
  2063.           The file interface allows FORTH to  use  the  screen  files.
  2064.           The utilities for listing the directory  and  erasing  files
  2065.           are loaded.  Also, the words for copying screens to and from
  2066.           FORTH disks are loaded from screen 7. 
  2067.  
  2068.  
  2069.  
  2070.  
  2071.  
  2072.                    USING" UTIL" last block in B:UTIL.SCR is 8 ok
  2073.                    8 LOAD ok
  2074.                    3 LOAD 4 LOAD 6 LOAD ok
  2075.                    WORDS
  2076.  
  2077.                    CURRENT and CONTEXT are FORTH
  2078.                    WORDS   TAB     TABSTOP         MORE?   DLIST   NEW     SIZE? 
  2079.                    BASE?   VOC?    VOC.    S?      DEPTH   ENDCASE         ENDOF
  2080.                    OF      CASE    #SCRCOPY        SCRCOPY         ASSIGN-BUF
  2081.                    COPY>SCR        COPY>FILE       PAUSE   ERASE"
  2082.                    . 
  2083.                    . 
  2084.                    . 
  2085.                    EOF B:UTIL .SCR 9216 07-20-1983 19:18 ok
  2086.  
  2087.           More utilities, including  NEW  to  update  the  COLD  start
  2088.           parameters, are loaded  from  the  UTIL  screen  file.   The
  2089.           vocabulary listing word WORDS is tested, and then  the  file
  2090.           is closed.
  2091.           8086/8088 FIG-FORTH User's Guide                     Page 44
  2092.           Appendix B - Building FORTH.COM
  2093.  
  2094.  
  2095.  
  2096.                    LOAD" EDITOR" last block in B:EDITOR.SCR is 6
  2097.  
  2098.                            FORTH, Inc.  editor
  2099.                    . 
  2100.                    . 
  2101.                    . 
  2102.                            editor loading, please wait... 
  2103.  
  2104.                    I MSG # 4 R MSG # 4
  2105.  
  2106.                    Current screen is 8 B:EDITOR .SCR 7168 07-19-83 2:53 ok
  2107.  
  2108.           The editor described in STARTING FORTH is loaded.  Note that
  2109.           LOAD" first lists screen 0, then begins loading at screen 1,
  2110.           and finally closes the file when the load is complete. 
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.                    NEW
  2117.                    current version is A
  2118.                    new version (A-Z)?  Bok
  2119.                    USING" FUTIL" last block in B:FUTIL.SCR is 10 ok
  2120.                    4 LOAD ok
  2121.                    EOF B:FUTIL .SCR 11264 07-20-1983 19:32 ok
  2122.  
  2123.           Here, the utilities to save FORTH are loaded.  Note that any
  2124.           words defined after executing NEW will not  be  saved,  and,
  2125.           that the file is closed before writing the new version. 
  2126.  
  2127.                    >FILE S4
  2128.                    S4 /SAVE-FORTH" FORTH.COM"
  2129.                    B:FORTH .COM - w c 13687 07-20-1983 19:41 ok
  2130.                     ok
  2131.                    BYE
  2132.                    B:FORTH
  2133.  
  2134.                    8086 FIG-FORTH Version 1.0B
  2135.                    WORDS
  2136.  
  2137.                    WHERE   EDITOR  LINE    TEXT    WORDS... 
  2138.  
  2139.                    EDITOR WORDS
  2140.  
  2141.                    r       u       i       s       f... 
  2142.  
  2143.                    BYE
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149.           END OF DOCUMENTATION
  2150.